import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:bubble_tab_indicator/bubble_tab_indicator.dart';

class BubbleTabIndicatorDemo extends StatefulWidget {
  const BubbleTabIndicatorDemo({Key key}) : super(key: key);

  @override
  _BubbleTabIndicatorDemoState createState() => _BubbleTabIndicatorDemoState();
}

class _BubbleTabIndicatorDemoState extends State<BubbleTabIndicatorDemo>
    with SingleTickerProviderStateMixin {
  final List<Tab> tabs = <Tab>[
    Tab(text: "周一"),
    Tab(text: "周二"),
    Tab(text: "周三"),
    Tab(text: "周四"),
    Tab(text: "周五"),
    Tab(text: "周六"),
    Tab(text: "周末")
  ];

  TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(vsync: this, length: tabs.length);
  }

  @override
  void dispose() {
    super.dispose();
    _tabController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Bubble Tab Indicator'),
        bottom: TabBar(
          isScrollable: true,
          unselectedLabelColor: Colors.grey,
          labelColor: Colors.white,
          indicatorSize: TabBarIndicatorSize.tab,
          indicator: BubbleTabIndicator(
            indicatorHeight: 44.0,
            
            indicatorColor: Colors.green,
            indicatorRadius: 50,
            insets: EdgeInsets.zero,
            padding: EdgeInsets.zero,
            tabBarIndicatorSize: TabBarIndicatorSize.tab,
            // Other flags
            // indicatorRadius: 1,
            // insets: EdgeInsets.all(1),
            // padding: EdgeInsets.all(10)
          ),
          tabs: tabs,
          controller: _tabController,
        ),
      ),
      body: TabBarView(
        controller: _tabController,
        children: tabs.map((Tab tab) {
          return Center(
              child: Text(
            tab.text,
            style: TextStyle(fontSize: 20.0),
          ));
        }).toList(),
      ),
    );
  }
}
